﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using ContactCenter.Core.Exceptions;
using ContactCenter.Core.DomainModel;
using ContactCenter.Core.Common;

namespace ContactCenter.Core.Tests
{
    [TestClass]
    public class ValidationHelperFixture
    {
        [TestMethod]
        [ExpectedException(typeof(InvalidContactInfoException))]
        public void ThrowsAnExceptionIfEmailInContactInfoIsNullOrEmpty()
        {
            var contactInfo = new ContactInfo("", "", "", "");
            ValidationHelper.ValidateContactInfo(contactInfo);
        }

        [TestMethod]
        [ExpectedException(typeof(InvalidCreditCardException))]
        public void ThrowsAnExceptionIfCreditCardHasExpired()
        {
            var creditCard = new CreditCard("1234-5678-9101", "1121", DateTime.Today.AddDays(-2));
            ValidationHelper.ValidateCreditCard(creditCard);
        }

        [TestMethod]
        [ExpectedException(typeof(InvalidCreditCardException))]
        public void ThrowsAnExceptionIfCreditCardHasNullNumber()
        {
            var creditCard = new CreditCard(string.Empty, string.Empty, DateTime.Today);
            ValidationHelper.ValidateCreditCard(creditCard);
        }

        [TestMethod]
        public void IfCardExpiresTodayItShouldBeValid()
        {
            var creditCard = new CreditCard("1234-5678-9101", "1121", DateTime.Today);
            ValidationHelper.ValidateCreditCard(creditCard);
        }
    }
}
